/*----------------------------------------------------------------------------------
Title : UIWindow自动生成脚本
Author: 呼呼
Description：UIWindow自动生成脚本，自动生成生命周期，对接Comp事件方法实现，自动生成子窗口
DataTime:2024/12/2 13:29:52
Warn: 此脚本由程序自动生成，请确保修改下面代码后不要重写生成脚本，否者将会覆盖原有内容!
----------------------------------------------------------------------------------*/
using DG.Tweening;
using UnityEngine;
public class CircleTransitionSceneWindow :WindowBase
{
	public CircleTransitionSceneWindowComp windowComp = new CircleTransitionSceneWindowComp();
    Material transitionMaterial;
    #region 生命周期
    public override void OnAwake()
	{
		 base.OnAwake();
		 windowComp.InitComp(this);
      
         transitionMaterial = windowComp.MaskImage.material;
         this.Log(transitionMaterial);
    }
	public override void OnShow()
	{
		 base.OnShow();
	}
	public override void OnHide()
	{
		 base.OnHide();
	}
	public override void OnDestroy()
	{
		 base.OnDestroy();
	}
    #endregion
    #region 组件事件
    #endregion
    public void PlayTransition(bool isEntering,float duration, System.Action onComplete = null)
    {
        if (transitionMaterial == null)
        {
            Debug.LogError("HurtAnimation not assigned!");
            return;
        }

        float startRadius = isEntering ? 0 : 1.2f;
        float endRadius = isEntering ? 1.2f : 0;

        transitionMaterial.SetFloat("_Radius", startRadius);
        DOTween.To(() => startRadius, x =>
        {
            startRadius = x;
            transitionMaterial.SetFloat("_Radius", startRadius);
        }, endRadius, duration).SetEase(Ease.InOutQuad).OnComplete(() =>
        {
            onComplete?.Invoke();
            if (isEntering)
            {
                uIService.HideWindow<CircleTransitionSceneWindow>();
            }
        });
    }
}
